public class SimpleGenericExample5 {

  public static void main(String[] args) {

    EmployeeUtil<Employee> employee = new EmployeeUtil<>(new Employee("Ram", 2000));
    EmployeeUtil<Manager>  manager  = new EmployeeUtil<>(new Manager("Krish", 3000));
    EmployeeUtil<Director> director = new EmployeeUtil<>(new Director("Nagesh", 3000));

    System.out.println(employee.isEqual(manager));
    System.out.println(director.isEqual(manager));
  }
}


class EmployeeUtil<T extends Employee> {

  private T employee;

  public EmployeeUtil(T employee) {
    this.employee = employee;
  }

  public int getSalary() {
    return this.employee.getSalary();
  }

  public boolean isEqual(EmployeeUtil<?> other) {
    return this.getSalary() == other.getSalary();
  }
}


class Employee {

  private String name;
  private int salary;

  public Employee(String name, int salary) {
    this.name = name;
    this.salary = salary;
  }

  public String getName() {
    return this.name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public int getSalary() {
    return this.salary;
  }

  public void setSalary(int salary) {
    this.salary = salary;
  }
}


class Manager extends Employee {

  public Manager(String name, int salary) {
    super(name, salary);
  }
}


class Director extends Employee {

  public Director(String name, int salary) {
    super(name, salary);
  }
}
